<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>LOL战力排行</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/lib/layui-v2.6.3/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all">
    <style>
        .layui-table td, .layui-table th {
            height: 60px;
            line-height: 60px;
            padding: 0;
            text-align: center;
        }
        .avatar-img {
            width: 50px;
            height: 50px;
        }
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form layui-form-pane" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">在线分配</label>
                <div class="layui-input-block">
                    <th:block th:each="user : ${lolRankUsers}">
                        <input type="checkbox" th:name="${user.name}"
                               lay-skin="tag"
                               th:title="${user.name} + '【' + ${user.currentScore} + '】'">
                    </th:block>
                </div>
            </div>
        </form>
        <button class="layui-btn layui-bg-blue" id="getDirectoryPath">开始组成5V5车队</button>
        <div class="layui-timeline">
            <div class="layui-timeline-item">
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title" id="one"></div>
                </div>
            </div>
            <div class="layui-timeline-item">
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title" id="two"></div>
                </div>
            </div>
            <div class="layui-timeline-item">
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title" id="dif"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/lib/layui-v2.6.3/layui.js}" charset="utf-8"></script>
<script th:src="@{/js/center.js}" charset="utf-8"></script>
<script th:src="@{/lib/jquery-3.4.1/jquery-3.4.1.min.js}" charset="utf-8"></script>
<script>
    $(document).ready(function() {
        var savedPath = localStorage.getItem('directoryPath');
        if (savedPath) {
            $('#directoryPath').val(savedPath);
        }
    });
    $('#getDirectoryPath').click(function () {
        var selectedNames = [];
        $('input[type=checkbox]:checked').each(function() {
            selectedNames.push($(this).attr('name'));
        });
        $.ajax({
            url: '/api/v1/LOL/startTeamIngUp',
            type: 'POST',
            data: JSON.stringify({ selectedNames: selectedNames }),
            contentType: 'application/json',
            success: function (response) {
                // 在成功响应中设置 cookie
                if (response.code === "00000") {
                    $('#one').html('诺克萨斯队: ' + response.data.team1.join(', '));
                    $('#two').html('艾欧尼亚队: ' + response.data.team2.join(', '));
                     $('#dif').html('两队分数比较: ' + response.data.dif);
                    layer.msg("分配成功...", {icon: 1,time:3000})
                }else {
                    layer.msg(response.message, {icon: 2,time:3000})

                }
            }
        });
    })
</script>
</body>
</html>